package org.peterrussell.contractionTimer.view;

/*
 * Created on Jun 30, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

import java.util.Calendar;
import java.util.Date;

/**
 * @author peterr
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class UIHelper {

	public static String dateToString(long time) {
	    Calendar cal = Calendar.getInstance();
	    cal.setTime(new Date(time));
	    //return  leftpad(String.valueOf(cal.get(Calendar.HOUR_OF_DAY)),2,'0') + ":"+
		return leftpad(String.valueOf(cal.get(Calendar.MINUTE)),2,'0')
		   + ":"+leftpad(String.valueOf(cal.get(Calendar.SECOND)),2,'0');
	}
	
	 public static String leftpad(String s, int length, char pad) {
		StringBuffer buffer = new StringBuffer(s);
		while (buffer.length() < length) {
			buffer.insert(0, pad);
		}
		return buffer.toString();
	}
}
